home *** CD-ROM | disk | FTP | other *** search
/ Amiga Collections: MegaDisc / MegaDisc 27 (1992-03)(MegaDisc Digital Publishing)(AU)(Disk 2 of 2).zip / MegaDisc 27 (1992-03)(MegaDisc Digital Publishing)(AU)(Disk 2 of 2).adf / NumbersUp_Game / numbersup.PROGRAMMERS < prev    next >
Text File  |  1992-03-30  |  13KB  |  292 lines

  1.  
  2.  
  3.                             ******************** 
  4.                             ***  NUMBERS UP  ***
  5.                             ********************
  6.  
  7.                                December, 1991. 
  8.  
  9.  
  10.    THIS GAME IS BASED EXACTLY ON THE GAME NUMBERSUP BY RICHARD RAMELLA AND
  11. ORIGINALLY PUBLISHED IN THE APRIL 1988 ISSUE OF JUMPDISK, THE ORIGINAL DISK
  12. MAGAZINE FOR THE AMIGA. DECLARED WITHIN THE PUBLIC DOMAIN BY RICHARD RAMELLA
  13. EFFECTIVE FEBRUARY 10, 1992.
  14.  
  15. ###########################################################################
  16. ###########################################################################
  17. ###########################################################################
  18. ##                                                                       ##
  19. ##  If you have any questions, comments, contributions, suggestions etc  ##
  20. ##                        PLEASE FORWARD THEM TO                         ##
  21. ##                                                                       ##
  22. ##                            Jason Lowe                                 ##
  23. ##                            5 Collaroy Close                           ##
  24. ##                            Chittaway Bay                              ##
  25. ##                            N.S.W 2259                                 ##
  26. ##                            Australia.                                 ##
  27. ##                                                                       ##
  28. ###########################################################################
  29. ###########################################################################
  30. ###########################################################################
  31.  
  32.  
  33.                  ************************************     
  34.                  ***  INFORMATION TO PROGRAMMERS  ***
  35.                  ************************************ 
  36.  
  37.                      Programmer:   Jason Lowe
  38.                             Age:   18
  39.                        Computer:   Amiga 500
  40.                          Extras:   2 MB ram, 20 MB harddisk, 
  41.                                    Laser Printer, External disk drive.
  42.                       Completed:   December, 1991.
  43.                        Comments:   - You can now use the space
  44.                                      bar aswell as the LMB!
  45.                                    - This is my first major program.
  46.                                      The idea was taken from Richard
  47.                                      Ramellas original game, "NUMBERSUP".
  48.  
  49.    THIS PROGRAM USES ANDERS BJERINS INCLUDESOUND TO PLAY THE SOUND FOUND 
  50. IN THIS PROGRAM. THANKS ANDERS. 
  51.  
  52.    NumbersUp was written in Aztec C v5.0a by Jason Lowe. If there is only
  53. the main source code with this game ( numbersup.c ) and none of the include
  54. files and you would like to see the complete source code, just write. Or
  55. if there is no source code at all with this program and you would like to
  56. see it just write.
  57.  
  58.    With this program I have written the whole game as many functions. I
  59. then test each function as best I can and then when I am happy with a
  60. particular function I will proceed to write more functions. With NumbersUp
  61. I firstly got numbers running from both sides of the screen, then worked
  62. out how to shoot them up, etc.
  63.  
  64.    The functions I have used in NumbersUp are, (in no particular order)
  65.  
  66.       - ViewInstructions
  67.       - ViewHighScores
  68.       - ClearSelected
  69.       - NumbersUp
  70.       - CheckHighScores  
  71.       - InitHighScores
  72.       - LoadHighScores
  73.       - CreateBrandNew
  74.       - CreateNew
  75.       - InitRandom
  76.       - Up
  77.       - DisplayScore
  78.       - InitScreen
  79.       - InitLoc
  80.       - idcmpch
  81.       - Open_Stuff
  82.       - die
  83.  
  84.    Now a small description of each of these functions,
  85.  
  86.    - ViewInstructions
  87.       This draws a image into the rastport. It is drawn if the user presses
  88.       the letter "I" at the main menu.
  89.  
  90.    - ViewHighScores
  91.       This will display the current top ten highscores. This is activated
  92.       if the user presses the right mouse button from the main menu. It is 
  93.       also activated if the user gets a high score.
  94.  
  95.    - ClearSelected
  96.       This clears the rectangular area where all the numbers are drawn. It
  97.       does no clear the main title "NumbersUp" and the surrounding border.
  98.  
  99.    - NumbersUp
  100.       This is the main game NumbersUp. It is called when the user presses
  101.       the left mouse button from the main menu.
  102.  
  103.    - CheckHighScores
  104.       This checks to see if the user has got a high. If the user has it
  105.       will change the high score list accordingly. It will also save the high
  106.       scores to disk if the user has previously specified.
  107.  
  108.    - InitHighScores
  109.       This will try to load the high score table from disk. If it is
  110.       sucsessful the high scores used while the program is active will be those
  111.       loaded from the disk. If it can't open a high score table it will create a
  112.       brand new one consisting of all ten names being JASON and all having 
  113.       scored 100 points.
  114.  
  115.    - LoadHighScore
  116.       This loads all the high scores from disk into memory. It uses a
  117.       string array for the names loaded called names and for the scores it 
  118.       uses an integer array called scores.
  119.  
  120.    - CreateBrandNew
  121.       This creates a brand new high score table consisting of ten names 
  122.       called JASON and ten scores of 100 points.
  123.  
  124.    - CreateNew
  125.       This creates a new disk file of high scores if the user gets a high
  126.       score AND the user wishes to save thier scores to disk.
  127.  
  128.    - InitRandom
  129.       This reseeds the random number generator.
  130.  
  131.    - Up
  132.       This sends a number up from a specific location on the screen. It is
  133.       called from the function NumbersUp when the user presses the left mouse 
  134.       button and a number is moving across the screen.
  135.  
  136.    - DisplayScore
  137.       This displays the current score. It is called from NumbersUp when the
  138.       user has sent a number up, and thier score has changed.
  139.  
  140.    - InitScreen
  141.       This draws the asterixes around the screen, so a border can specify
  142.       where the number can go.
  143.  
  144.    - InitLoc
  145.       This clears all data about what numbers are where. It clears the
  146.       variable loc out such that the computer thinks there are no numbers on the
  147.       screen.
  148.  
  149.    - idcmpch
  150.       This checks the IDCMP. It returns 1 for a left mouse button press, or
  151.       2 for a right mouse button press, or the raw value for any key pressed on
  152.       the key board.
  153.  
  154.    - Open_Stuff
  155.       Opens the libraries needed, a screen, and a window.
  156.  
  157.    - die
  158.       Frees everthing that needs freeing and also closes everything that
  159.       needs closing.
  160.    
  161.  
  162.  
  163.    As I said above with this game, I test each fuction before proceeding to
  164. write another. Heres the steps I used in writting Numbers Up.
  165.  
  166.    1) Firstly get numbers flying in from both sides of the screen.
  167.  
  168.       As you can see with this program, the numbers fly across very
  169. smoothly IF you don't have many tasks in the background. I was originally
  170. going to use sprites for the numbers which flew across the screen. But I
  171. found another method which used very little memory and most importantly the
  172. numbers flew across very smoothly. 
  173.       As you know with sprites, when you move them around the screen the
  174. hardware of the Amiga redraws what was under the sprite then redraws the
  175. sprite where you want it to go. But what if you only want to move an object
  176. around the screen and are not worried about redrawing the display under the
  177. object. Obviously you wouldn't need sprites, but they COULD be used. 
  178.       As you see in Numbers Up when a number flys in from one side of the
  179. screen there is nothing under the number which needs to be redrawn. The
  180. only function I used to scroll the numbers across the screen was Text(). If
  181. you haven't used this function before, it simply writes a string to a
  182. particular rastport. 
  183.       When I have randomly picked the number which is to fly across the
  184. screen, I simply create a string with only this number in it. BUT in the
  185. string with the number I also write TWO spaces. One either side of the
  186. number. For example, if I want to send the number six across, I would
  187. create a string like this,
  188.                               " 6 "
  189.                           and I guess you can see why. If you move
  190. the number only a few pixels to the left or to the right of where it
  191. originally was it would completely wipe the old image out. This results in
  192. quite smooth scrolling of the numbers. This may not sound all that
  193. fantastic but it sure did save me from reserving sprites, and also reserving
  194. the sprite data for each of the 9 numbers which need to fly across!
  195.  
  196.  
  197.  
  198.  
  199.    2) Once I had the numbers flying across the screen quite smoothly, I 
  200. then proceeded to write a function which moved a particular number up the
  201. screen at a particular location. 
  202.  
  203.       The name of this function is "up()". If you look at the C source for
  204. numbersup, you will see that I have declared a global variable ( accessable
  205. by all functions) called "xpos". The function NumbersUp, changes the value
  206. of xpos as the number moves across the screen. I move the number 4 pixels
  207. each Screen Refresh, which means it moves quite smoothly and at a decent
  208. playable speed. 
  209.       But you may ask, how do you work out where the number gets shot up
  210. seeing that the width of a number is 8 pixels! Actually I thought this may
  211. be a downfall in the game, but it turned out to work quite well. If the
  212. user decides to shoot a number up when it is halfway between where it
  213. should go I simply move it another 4 pixels in the direction it is going
  214. and then move it up the screen. Because the numbers are moving so fast, the
  215. average user can not tell what is happening!
  216.  
  217.  
  218.  
  219.  
  220.    3) The next step was to check where the numbers should end up once they
  221. where shot up.
  222.  
  223.       I did this simply by creating an array, and storing each of the
  224. numbers shot up at a particular location in the array. With this array, I
  225. could simply add up the users score and also check to see if the user has
  226. put two numbers together which are the same. This array is cleared at the
  227. beginning of game and all the locations in the array are set to zero. This
  228. way I can check to see if there is a number at a particular location simply
  229. by testing if the array location dosen't equal zero!
  230.  
  231.    
  232.  
  233.       Once I had the numbers running across smoothly, the score adding up
  234. each game correctly and checking correctly if it was game over, it was time
  235. to display the score, display when its game over etc.
  236.       The function DisplayScore(), simply writes the current score at the
  237. top of the screen. It is called when the user sends a number up regardless
  238. of whether they have scored addition points or not.
  239.       Then once the main idea behind Numbers Up was working ok I then
  240. created a high Score table, added graphics and sound to liven things
  241. up. 
  242.  
  243.                  ****   THE HIGH SCORE TABLE   ****
  244.  
  245.       There are two variables which hold the high score table. These are
  246. 'names' ( declared as a character array with 12 arrays each of 80
  247. characters) and also 'scores' ( declared as an array of 12 of type
  248. integer). The variable 'names' stores the names of the top ten people's
  249. names. The variable 'scores' stores the top ten scores.
  250.  
  251.       When the user has scored a high score, I simply change the these two
  252. arrays and also save the scores to disk IF the user has previously
  253. specified.   
  254.       There are 6 functions used in the manipulation of the high scores.
  255. They are all explained above.
  256.  
  257.                      ****   THE GRAPHICS   ****
  258.  
  259.       The graphics of this program where designed with Deluxe Paint. They
  260. are simple and make the program stand out. I converted the graphic images
  261. to C source with PowerSource. PowerSource is an excellent program for
  262. creating C source from graphic images as everything is done visually and
  263. not through the CLI.
  264.       The game originally had no graphics and had a simple requestor which 
  265. asked you what you want to do. A freind then told me that I should make 
  266. the game more attractive, I did, and when you first load the game up it 
  267. looks interesting! 
  268.  
  269.                        ****   THE SOUND   ****
  270.  
  271.       The sound found in this program is taken from Public Domain Sources.
  272. I originally loaded the sounds from disk, but now have found a new program
  273. ( Written by Anders Bjerin ) which enables you to include all sound effects
  274. with the the main program. Very handy!
  275.  
  276.  
  277.       I suppose your wondering. Was it all that simple. Well the answer to
  278. that was NO. My original version of numbers up was nothing compared to this
  279. one. It jerked the numbers across the screen very slowly and it was
  280. incredibly easy to score thousands of points. Plus the fact that each game
  281. seem to take an eternity to play. I had to do something, and did.
  282.  
  283.       Well thats the end of this doc file, I would like to go into more
  284. depth about this game but it would be to time consuming to cover everything,
  285. so if you've got any questions about what happens during this game, don't
  286. hesistate to write. In the mean time...
  287.  
  288.             ***   HAPPY PROGRAMMING AND COMPUTING!   ***
  289.  
  290.  
  291.                                THE END
  292.